
<template>
  <main-container :headerText="'充值管理 >> 充值页面'">
    <div class="content">
      <div class="content">
        <div class="edit-wrap">
          <div class="top-input">
            <div class="item">
              <label for> <span class="tips">* </span>用户手机号： </label>
              <div class="inline-block">
                <el-input
                  v-model="formData.tel"
                  placeholder="请输入商品名称"
                  size="small"
                  style="width: 220px"
                ></el-input>
              </div>
            </div>

            <div class="submit-option">
              <el-button @click="getDetailData" size="small" type="primary"
                >搜索</el-button
              >
            </div>

            <div class="edit-wrap">
              <div class="top-input">
                <div class="item">
                  <label for>提示：:</label>
                  <div class="inline-block">{{tips}}</div>
                </div>

                <div class="item">
                  <label for>用户手机号:</label>
                  <div class="inline-block">{{ userData.phone }}</div>
                </div>

                <div class="item">
                  <label for>用户id:</label>
                  <div class="inline-block">{{ userData.id }}</div>
                </div>
              </div>
            </div>

            <div>
              <div class="item">
                <label for> <span class="tips">* </span>请输入金额： </label>
                <div class="inline-block">
                  <el-input
                    v-model="formData.balance"
                    placeholder="请输入商品名称"
                    size="small"
                    style="width: 220px"
                  ></el-input>
                </div>
              </div>

              <div class="submit-option">
                <el-button @click="chargeF" size="small" type="primary"
                  >充值</el-button
                >
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main-container>
</template>


<script>
import jhTools from "@/utils/jhTools"; //工具函数
import API from "@/utils/api_config.js"; //引入api

import main_container from "@/components/main_container";
import top_option from "@/components/subCon/topOption";
import input_search from "@/components/subCon/inputSearch";
import select_search from "@/components/subCon/selectSearch";
import date_search from "@/components/subCon/dateSearch";
import upload_img from "@/components/subCon/upload_img";

export default {
  components: {
    "main-container": main_container,
    "top-option": top_option,
    "input-search": input_search,
    "select-search": select_search,
    "date-search": date_search,
    "upload-img": upload_img,
  },
  props: {},
  data() {
    return {
      formData: {
        tel: "",
        balance: 0, //余额
      },
      userData: {},

      allMethods: "",
      tips: "提示",
    };
  },
  mounted() {
    this.allMethods = this.getAllMethods();

    const id = this.$route.query.id;
  },
  methods: {
    /* 充值 */
    chargeF() {
      let url = API.charge_m.charge;
      let data = {
        balance:Number(this.formData.balance),
        userId: this.userData.id,
      };
      console.log("参数", data);
      jhTools.post(
        url,
        data,
        data,
        (res) => {
          console.log("结果", res);
          if (res.code == 200) {
              console.log("暂无数据");
              this.tips = "充值成功！！";
          }
        },
        (err) => {
          console.log(err);
        }
      );
    },

    //获取编辑数据
    getDetailData(tel) {
      let url = API.charge_m.get_user_info;
      let data = {
        tel: this.formData.tel,
      };
      console.log("参数", data);
      jhTools.get(
        url,
        null,
        data,
        (res) => {
          console.log("结果", res);
          if (res.code == 200) {
            if (!res.data || res.data.length == 0) {
              console.log("暂无数据");
              this.tips = "暂无数据";
              this.userData = [];
              return;
            } else {
              this.userData = res.data;
            }
          }
        },
        (err) => {
          console.log(err);
        }
      );
    },

    //返回
    handleGoBack() {
      this.$router.go(-1);
    },
    /* 方法抽离集合 */
    getAllMethods() {
      var _this = this;
      return {};
    },
  },
};
</script>

<style lang="scss" scoped>
// @import '~styles/mixins.scss';
// @import '~styles/variables.scss';

/* 操作栏相关*/

.content {
  min-height: 100%;
}

.top-option {
  min-height: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  border-bottom: 1px solid #efefef;
  margin: 0 30px;
  padding: 10px 0;

  .left-box {
    padding-left: 30px;
    max-width: 900px;

    .sub {
      float: left;
      width: 200px;
      margin-left: 10px;
      margin-top: 10px;
    }
  }

  .right-box {
    padding-right: 30px;
    // min-width: 300px;

    .sub {
      float: right;
      margin-left: 10px;
      margin-top: 10px;
    }
  }
}

/* 操作栏相关*/

/* 输入*/
.edit-wrap {
  padding: 40px;
  border-radius: 10px;
  background-color: #fff;
  font-size: 14px;

  label {
    display: inline-block;
    width: 120px;
    text-align: right;
  }
  .tips {
    color: #f10215;
  }
  //标题
  .title {
    height: 46px;
    font-size: 14px;
    padding-left: 20px;
    font-weight: bold;
    line-height: 46px;
  }

  .top-input {
    .item {
      margin-top: 10px;

      &.img-item {
        display: flex;
        flex-direction: row;
      }
    }
  }

  .submit-option {
    padding-top: 60px;
    padding-bottom: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

//调整element 样式
.inline-block {
  display: inline-block;
  margin-left: 22px;
  &.id {
    padding-left: 20px;
  }

  el-input {
    width: 20px !important;
  }
}

//详情图片
.img-item {
  display: flex;
  flex-direction: row;
  .img-box {
    width: 160px;
    img {
      width: 100%;
    }
  }
}

//按钮
.submit-option {
  width: 300px;
  padding-top: 30px;
  padding-bottom: 60px;
  padding-left: 100px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

/* 上传按钮样式*/
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid #ddd;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 107px;
  height: 107px;
  line-height: 107px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.avatar {
  width: 107px;
  height: 107px;
  display: block;
}
</style>